var appVue=new Vue({
  el: '#merchantAppAdd',
  data: {
	marchant:{
		merchantName:'',
		contactTel:'',
		email:'',
		contactName:'',
		address:'',
		phoneSwitct:'false',
		callkeSwitch:'false',
		depositSwitch:'false'
	}
  },
  methods:{
	  addMerchant(){
		  
		  //查询商户,将this指针指向_self对象，方便后续调用
		  var _self=this;
		  if(_self.marchant.merchantName==""){
	    		layer.tips('商户名称必填', '#merchantName', {
	    			  tips: [2, '#FF5722'],
	    			  time: 2000
	    		});
	    		return;
	      }
		  if(_self.marchant.contactTel==""){
	    		layer.tips('联系电话必填', '#contactTel', {
	    			  tips: [2, '#FF5722'],
	    			  time: 2000
	    		});
	    		return;
	      }
		  if(_self.marchant.contactName==""){
	    		layer.tips('联系人必填', '#contactName', {
	    			  tips: [2, '#FF5722'],
	    			  time: 2000
	    		});
	    		return;
	      }
		  if(_self.marchant.merchantName==""){
	    		layer.tips('商户名称必填', '#queryProjectId', {
	    			  tips: [2, '#FF5722'],
	    			  time: 2000
	    		});
	    		return;
	      }
		  $.ajax({
		        url: appConfig.apiUrl+"/merchant/add",
		        type: "post",
		        data:_self.marchant,
		        dataType: 'json',
		        success: function(data) {
		        	if(data.head.success==true){
		        		layer.alert('商户开户成功！',{
		        			  skin: 'layui-layer-molv' //样式类名
		        			  ,closeBtn: 0
		        			}, function(){
		        				window.location.href='list.html'
		        			}
		        		);
		        	}else{
		        		layer.alert(data.head.message);
		        	}
                  
		        },
		        error: function() {
		            alert("超时");
		        }
		    });
	  }
  }
})